#!/usr/bin/make

# ------------------------------------------------------------------------
# Author     : Weilun Fong | wlf@zhishan-iot.tk
# Date       : 2020-02-06
# Description: help Makefile
# E-mail     : mcu@zhishan-iot.tk
# Make-tool  : GNU Make (http://www.gnu.org/software/make/manual/make.html)
# Page       : https://hw.zhishan-iot.tk/page/hml/detail/fwlib_stc89.html
# Project    : HML_FwLib_STC89
# Version    : v0.3.1
# ------------------------------------------------------------------------

# Check run environment
ifneq ($(MAKELEVEL), 1)
    $(error It's not allowed to execute this makefile directly!)
endif

# Print help information
help:
	@$(ECHO)  "Build:"
	@$(ECHO)  "    all        - Build target(include HML library file and user code)"
	@$(ECHO)  "    library    - Only build HML library file"
	@$(EECHO) "    rebuild    - Rebuild target(include HML library file and user code). In this case, \
-j can't work and please pass \033[3mJOBS\033[0m variable via command line instead of it, such as \"make rebuild JOBS=8\""
	@$(ECHO)  ""
	@$(ECHO)  "Cleaning:"
	@$(ECHO)  "    clean      - Delete temporary files created by build, except for the .lib and .hex files"
	@$(ECHO)  "    distclean  - Delete all temporary files and generated library file"
	@$(ECHO)  ""
	@$(ECHO)  "Info:"
	@$(ECHO)  "    help       - Show help information"
	@$(ECHO)  "    version    - Show version information"
	@$(ECHO)  ""
	@$(ECHO)  "+ MCU config variable:"
	@$(ECHO)  "    MCU        - Specify MCU model(case-insensitive), this variable is required by all \
compilation target, including all, library and rebuild"
	@$(ECHO)  "    CLKFRE     - Specify clock frequency manually(unit: Hz)"
	@$(ECHO)  "    PRESCALER  - Specify MCU prescaler factor, the value must be 6(6T mode) or 12(12T mode)"
	@$(ECHO)  "    CODE       - Specify total size of ROM(external+ on-chip) during compilation manually (unit: KB)"
	@$(ECHO)  "    XRAM       - Specify total size of external RAM during compilation manually (unit: KB)"
	@$(ECHO)  ""
	@$(ECHO)  "+ command line variable:"
	@$(ECHO)  "    CONF       - Specify config Makefile(default: Makefile.config)"
	@$(ECHO)  "    JOBS       - Specify number of make job(only for make rebuild)"
	@$(ECHO)  "    MYFILE     - Specify user source file or Makefile will fill it with \"test.c\". It's \
noticed that once use this option to compile specified .c file, user should add this option during doing \
other works, such as clean and rebuild."
	@$(ECHO)  "    VERBOSE    - When the value is 1, Makefile will print more details during build"
	@$(ECHO)  ""
	@$(ECHO)  "Examples:"
	@$(ECHO)  "    (1) make -j"
	@$(ECHO)  "    (2) make -j MCU=stc89c52rc"
	@$(ECHO)  "    (3) make rebuild MCU=stc89c52rc JOBS=4"
	@$(ECHO)  "    (4) make -j library MCU=stc89c52rc"
